import React from 'react'
import constants from "share/constants";
import RefundRule from 'containers/finance-setting/loan-setting/slide-content/refund-rule'
import PrintRule from 'containers/finance-setting/loan-setting/slide-content/print-rule'
import LoanRule from 'containers/finance-setting/loan-setting/slide-content/loan-rule'
import PayBasicRule from 'containers/finance-setting/loan-setting/slide-content/pay-basic-rule'
import PayTypeRule from 'containers/finance-setting/loan-setting/slide-content/pay-type-rule'
import AuthorizationRule from 'containers/finance-setting/loan-setting/slide-content/authorization-rule'
import ApyTypeRule from 'containers/finance-setting/loan-setting/slide-content/apy-type-rule'
import AccountRule from 'containers/finance-setting/loan-setting/slide-content/account-rule'
import PeriodDefineRule from "containers/finance-setting/period-define/period-define-rule";
import SubjectRule from "containers/finance-setting/subject-sheet/subject-rule";
import CashRule from "containers/finance-setting/loan-setting/slide-content/cash-rule";
import { messages, queryCurrencyPrecision } from "share/common";
import { Badge, Modal, Popover, Radio } from "antd";
import moment from "moment";
import menuRoute from "routes/menuRoute";
import SlideFrame from "components/slide-frame";
import ViewLine from "containers/loan-billing/template/view-line";
import openSlideFrame from "share/openSlideFrame";
import ExportRule from "../../pay-setting/export-template-setting/export-rule";
import Importer from "components/template/importer/index";

const refundStatus = [
  { label: messages('common.all')/*全部*/, value: '100' },
  { label: messages('finance-1.key236')/*待确认*/, value: '1001' },
  { label: messages('finance-1.key237')/*已完成*/, value: '1002' },
  { label: messages('finance-1.key238')/*已驳回*/, value: '1003' }
];

const loanStatus = [
  { label: messages('common.all')/*全部*/, value: '1000' },
  { label: messages('finance-1.key67')/*有欠款*/, value: '1005' },
  { label: messages('finance-1.key237')/*已完成*/, value: '1007' }
];

const writeOffRule = {
  '1': messages('finance-1.key239')/*本位币 - 本位币*/,
  '2': messages('finance-1.key240')/*外币 - 外币*/,
  '4': messages('finance-1.key241')/*外币 - 本位币*/,
  '8': messages('finance-1.key242')/*本位币 - 外币*/
};

const refundType = {
  '1': messages('finance-1.key8')/*现金还款*/,
  '2': messages('finance-1.key9')/*转账还款*/,
  '4': messages('finance-1.key204')/*额度还款*/
};

const formatType = {
  '1': 'XLSX',
  '2': 'XLS',
  '4': 'CSV',
  '8': 'TXT'
};
/* columns */
const levelCode = { dataIndex: 'levelCode', title: messages('finance-1.key243')/*层级*/, render: value => constants.levelCode[value]};

const isEnable = { dataIndex: 'isEnable', title: messages('common.column.status')/*状态*/, render: value => <Badge
    status={value ? 'success' : 'error'}
    text={value ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key245')/*禁用temp*/}
  /> };

const optionPrintTemp = { dataIndex: 'optionPrintTemp', title: messages('finance-1.key246')/*打印模版*/, render: value => value === '1' ? messages('finance-1.key247')/*多行模板*/ : messages('finance-1.key248')/*单行模板*/ };

const optionPrintDrc = { dataIndex: 'optionPrintDrc', title: messages('finance-1.key249')/*打印方向*/, render: value => value === '1' ? messages('finance-1.key250')/*横向*/ : messages('finance-1.key251')/*纵向*/ };

const optionWithLine = { dataIndex: 'optionWithLine', title: messages('finance-1.key252')/*借款行信息*/, render: value => value === '1' ? messages('common.print')/*打印*/ : messages('finance-1.key253')/*不打印*/ };

const optionEncryptedBc = { dataIndex: 'optionEncryptedBc', title: messages('finance-1.key254')/*银行信息*/, render: value => value === '1' ? messages('finance-1.key255')/*加密*/ : messages('finance-1.key256')/*不加密*/ };

const optionWithAppHist = { dataIndex: 'optionWithAppHist', title: messages('finance-1.key62')/*审批历史*/, render: value => value === '1' ? messages('common.print')/*打印*/ : messages('finance-1.key253')/*不打印*/ };

const paymentMethodCategoryName = { title: messages('finance-1.key26')/*付款方式类型*/, dataIndex: 'paymentMethodCategoryName' };

const paymentMethodCode = { title: messages('finance-1.key257')/*付款方式代码*/, dataIndex: 'paymentMethodCode' };

const description = { title: messages('finance-1.key258')/*付款方式名称*/, dataIndex: 'description' };

const isEnabled = { title: messages('common.column.status')/*状态*/, dataIndex: 'isEnabled', render: value => <Badge
    status={value ? 'success' : 'error'}
    text={value ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key245')/*禁用temp*/}
  /> };

const ablePaymentMethods = {
  title: messages('finance-1.key259')/*启用付款方式类型*/, dataIndex: 'ablePaymentMethods',
  render: value => value.map(item => constants.paymentMethod[item]).join(',')
};

const defPaymentMethods = {
  title: messages('finance-1.key260')/*默认付款方式类型*/, dataIndex: 'defPaymentMethods',
  render: value => value.map(item => constants.paymentMethod[item]).join(',')
};

const isPartPay = { title: messages('finance-1.key261')/*部分支付*/, dataIndex: 'isPartPay', render: value => value ? messages('common.yes')/*是*/ : messages('common.no')/*否*/ };

const isPayCheck = { title: messages('finance-1.key262')/*线上付款复核*/, dataIndex: 'isPayCheck', render: value => value ? messages('common.yes')/*是*/ : messages('common.no')/*否*/  };

const isEnablt = { dataIndex: 'isEnablt', title: messages('common.column.status')/*状态*/, render: value => <Badge
    status={value ? 'success' : 'error'}
    text={value ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key245')/*禁用temp*/}
  /> };

const content = {
  title: messages('finance-1.key263')/*配置内容*/, dataIndex: 'content', render: (value, record) => (
    <Popover content={<div>
      <div>{messages('finance-1.key264')/*【核销配置】*/}</div>
      <div>{messages('finance-1.key265')/*启用核销*/}:{record.option1 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/}</div>
      <div>{messages('finance-1.key267')/*多核销*/}:{record.option2 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/}</div>
      <div>{messages('finance-1.key268')/*专项核销*/}:{record.option3 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/}</div>
      <div>{messages('finance-1.key269')/*核销币种规则*/}:{record.writeOffRules && record.writeOffRules.map(item => writeOffRule[item]).join(',')}</div>
      <div>{messages('finance-1.key270')/*【还款配置】*/}</div>
      <div>{messages('finance-1.key271')/*启用还款单*/}:{record.option5 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/}</div>
      <div>{messages('finance-1.key7')/*还款方式*/}:{record.repaymenTypes && record.repaymenTypes.map(item => refundType[item]).join(',')}</div>
      <div>{messages('finance-1.key272')/*部分还款*/}:{record.option7 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/}</div>
      <div>{messages('finance-1.key273')/*财务确认可修改*/}:{record.option8 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/}</div>
      <div>{messages('finance-1.key274')/*附件必传*/}:{record.option9 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/}</div>
    </div>} placement={'topRight'}>
      {messages('finance-1.key265')/*启用核销*/}:{record.option1 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/};
      {messages('finance-1.key267')/*多核销*/}:{record.option2 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/};
      {messages('finance-1.key268')/*专项核销*/}:{record.option3 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/};
      {messages('finance-1.key269')/*核销币种规则*/}:{record.writeOffRules && record.writeOffRules.map(item => writeOffRule[item]).join(',')};
      {messages('finance-1.key271')/*启用还款单*/}:{record.option5 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/};
      {messages('finance-1.key7')/*还款方式*/}:{record.repaymenTypes && record.repaymenTypes.map(item => refundType[item]).join(',')};
      {messages('finance-1.key272')/*部分还款*/}:{record.option7 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/};
      {messages('finance-1.key273')/*财务确认可修改*/}:{record.option8 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/};
      {messages('finance-1.key274')/*附件必传*/}:{record.option9 === 'true' ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key266')/*不启用*/};
    </Popover>
  )
};

const classCode = { title: messages('finance-1.key275')/*借款类型代码*/, dataIndex: 'classCode' };

const loanDescription = { title: messages('finance-1.key276')/*借款类型名称*/, dataIndex: 'description' };

const optionalEptFmt = { title: messages('finance-1.key277')/*导出格式*/, dataIndex: 'optionalEptFmt', render: value => formatType[value] };

const optionalEntryFmt = {
  title: messages('finance-1.key278')/*导出样式*/, dataIndex: 'optionalEntryFmt',
  render: value => value === '1' ? messages('finance-1.key279')/*头行合并*/ : messages('finance-1.key280')/*头行分离*/
};

const apiEntryFmt = {
  title: messages('finance-1.key281')/*接口样式*/, dataIndex: 'apiEntryFmt',
  render: value => value === '1' ? messages('finance-1.key279')/*头行合并*/ : messages('finance-1.key280')/*头行分离*/
};

const periodSetCode = { title: messages('finance-1.key282')/*会计期编码*/, dataIndex: 'periodSetCode' };

const periodSetName = { title: messages('finance-1.key283')/*会计期名称*/, dataIndex: 'periodSetName' };

const totalPeriodNum = { title: messages('finance-1.key284')/*期间总数*/, dataIndex: 'totalPeriodNum' };

const periodAdditionalFlagDes = { title: messages('finance-1.key285')/*名称附加*/, dataIndex: 'periodAdditionalFlagDes' };

const levelOrgName = { title: messages('finance-1.key286')/*所属组织*/, dataIndex: 'levelOrgName' };

const distributionList = {
  title: messages('finance-1.key287')/*启用公司*/, dataIndex: 'distributionList',
  render: (value, record) => {
    let res = record.isGlobal ? messages('finance-1.key288')/*通用*/ : value && value.map(item => item.levelOrgName).join(',');
    return <Popover content={res} placement={'topLeft'}>{res}</Popover>
  }
};

const fmRepaymentOptionDistList = {
  title: messages('finance-1.key287')/*启用公司*/, dataIndex: 'fmRepaymentOptionDistList',
  render: (value, record) => {
    let res = record.isGlobal ? messages('finance-1.key288')/*通用*/ : value && value.map(item => item.levelOrgName).join(',');
    return <Popover content={res} placement={'topLeft'}>{res}</Popover>
  }
};

const fmLoanOptionDistList = {
  title: messages('finance-1.key287')/*启用公司*/, dataIndex: 'fmLoanOptionDistList',
  render: (value, record) => {
    let res = record.isGlobal ? messages('finance-1.key288')/*通用*/ : value && value.map(item => item.levelOrgName).join(',');
    return <Popover content={res} placement={'topLeft'}>{res}</Popover>
  }
};

const fmPaymentOptionDistList = {
  title: messages('finance-1.key287')/*启用公司*/, dataIndex: 'fmPaymentOptionDistList',
  render: (value, record) => {
    let res = record.isGlobal ? messages('finance-1.key288')/*通用*/ : value.map(item => item.levelOrgName).join(',');
    return <Popover content={res} placement={'topLeft'}>{res}</Popover>
  }
};

const enabled = {
  title: messages('common.column.status')/*状态*/, key: "enabled", dataIndex: 'enabled',
  render: isEnabled => <Badge status={isEnabled ? 'success' : 'default'} text={isEnabled ? messages('finance-1.key244')/*启用temp*/ : messages('finance-1.key245')/*禁用temp*/}/>
};

const currencyCode = { title: messages('common.currency')/*币种*/, dataIndex: 'currencyCode', width: 60 };

const payeeCode = { title: messages('finance-1.key289')/*工号/供应商编号*/, dataIndex: 'payeeCode' };

const payeeName = { title: messages('finance-1.key70')/*收款人*/, dataIndex: 'payeeName' };

const loanCompanyName = { title: messages('finance-1.key79')/*借款公司*/, dataIndex: 'companyName' };

const origDocumentSequence = { title: messages('finance-1.key290')/*凭证号*/, dataIndex: 'origDocumentSequence', hide: true };

const remark = {
  title: messages('finance-1.key87')/*事由说明temp*/, dataIndex: 'remark',
  render: value =>  <Popover placement="topLeft" content={value}>{value}</Popover>
};

/* searchForm */

const paymentMethodCodeSearch = {
  id: 'paymentMethodCode', label: messages('finance-1.key26')/*付款方式类型*/, component: 'Input',
  props: { placeholder: messages('finance-1.key76')/*请输入temp2*/ },
  dataIndex: 'paymentMethodCode'
};

const descriptionSearch = {
  id: 'description', label: messages('finance-1.key26')/*付款方式类型*/, component: 'Input',
  props: { placeholder: messages('finance-1.key76')/*请输入temp2*/ },
  dataIndex: 'description'
};

const periodSetCodeSearch = {
  id: 'periodSetCode', label: messages('finance-1.key282')/*会计期编码*/, component: 'Input',
  props: { placeholder: messages('finance-1.key76')/*请输入temp2*/ },
  dataIndex: 'periodSetCode'
};

const setOfBooksCodeSearch = {
  id: 'setOfBooksCode', label: messages('finance-1.key291')/*账套编码*/, component: 'Input',
  props: { placeholder: messages('finance-1.key76')/*请输入temp2*/ },
  dataIndex: 'setOfBooksCode'
};

const accountSetCodeSearch = {
  id: 'accountSetCode', label: messages('finance-1.key292')/*科目表编码*/, component: 'Input',
  props: { placeholder: messages('finance-1.key76')/*请输入temp2*/ },
  dataIndex: 'accountSetCode'
};

const accountSetDescSearch = {
  id: 'accountSetDesc', label: messages('finance-1.key293')/*科目表名称*/, component: 'Input',
  props: { placeholder: messages('finance-1.key76')/*请输入temp2*/ },
  dataIndex: 'accountSetDesc'
};

const setOfBooksNameSearch = {
  id: 'setOfBooksName', label: messages('finance-1.key294')/*账套名称*/, component: 'Input',
  props: { placeholder: messages('finance-1.key76')/*请输入temp2*/ },
  dataIndex: 'setOfBooksName'
};

const payeeKey = {
  id: 'payeeKey', label: messages('finance-1.key70')/*收款人*/, component: 'Input',
  props: { placeholder: messages('finance-1.key295')/*请输入姓名/工号/供应商编号/供应商名称*/ },
  parser: value => ({ payeeKey : value ? encodeURI(value) : undefined }),
  dataIndex: 'payeeName'
};

const loanCompanyNameSearch = {
  id: 'companyName', label: messages('finance-1.key79')/*借款公司*/, component: 'Input',
  props: { placeholder: messages('finance-1.key73')/*请输入公司名称*/ },
  dataIndex: 'companyName'
};

const dataRange = {
  id: 'dataRange', label: messages('common.submit.date')/*提交日期*/, component: 'DateRangePicker',
  parser: value => ({
    startDateTime: value && value[0] ? moment(value[0]).format('YYYY-MM-DD 00:00:00') : undefined,
    endDateTime: value && value[1] ? moment(value[1]).format('YYYY-MM-DD 23:59:59') : undefined
  }),
  dataIndex: 'createDate'
};

const employeeKey = { id: 'employeeKey', label: messages('finance-1.key296')/*借款人*/, component: 'Input' };

const _this = React.Component.prototype;

let setContext;

const companyId = {
  id: 'companyIds', label: messages('finance-1.key72')/*公司*/, component: 'Chooser',
  props: {
    type: 'available_company_setOfBooks',
    placeholder: messages('finance-1.key73')/*请输入公司名称*/,
    listExtraParams: { enabled: true },
    valueKey: 'id',
    single: true,
    labelKey: 'name'
  },
  parser: value => ({
    companyIds: value && value.length ? value[0].id : null
  }),
  dataIndex: 'companyName'
};

const loanTypeId = context => ({
  id: 'loanTypeId', label: messages('finance-1.key17')/*借款类型*/, component: 'Chooser',
  props: {
    type: 'loan_cash_type',
    listExtraParams: { typeCode: 'PREPAYMENT', tenantId: context.props.loginUser.tenantId },
    valueKey: 'id',
    single: true,
    labelKey: 'description'
  },
  parser: value => ({
    loanTypeId: value ? value.map(item => item.id) : null
  }),
  dataIndex: 'loanTypeName'
});

const currencyCodeForm = context => ({
  id: 'currencyCode', label: messages('common.currency')/*币种*/, component: 'Selector',
  props: {
    type: 'currency',
    params: { userOId: context.props.loginUser.userOID },
    filter: item => item.enable,
    showSearch: true
  },
  dataIndex: 'currencyCode'
});

const remarkForm = {
  id: 'remark', label: messages('finance-1.key75')/*事由*/, component: 'Input',
  props: { placeholder: messages('finance-1.key76')/*请输入*/ },
  dataIndex: 'remark'
};

/* 操作 */
const handleLoanRowClick = (e, record) => {
  e.stopPropagation();
  openSlideFrame.openLoanReport({
    formOID: record.formOid,
    loanBillOID: record.loanBillOid,
    pathname: 'loan-and-refund'
  }, {
    afterClose: value => {typeof value === 'boolean' && value && setContext.tableRef.getList()}
  }, setContext);
};

export default {

  formItemLayout: {
    labelCol: {
      xs: { span: 24 },
      sm: { span: 6 },
    },
    wrapperCol: {
      xs: { span: 24 },
      sm: { span: 10 },
    },
  },

  getContext(context) {
    setContext = context;
  },

  /*还款设置*/
  Refund: {
    title: messages('finance-1.key297')/*还款设置*/,
    description: messages('finance-1.key298')/*您可在此页面配置报销单核销借款业务、还款单业务的参数。*/,
    columns: [levelCode, levelOrgName, fmRepaymentOptionDistList, content, isEnable],
    form: [],
    url: '/api/repayment/option/list',
    deleteUrl: '/api/repayment/option/delete?optionId',
    rule: RefundRule,
    icon: 'book'
  },
  /*打印设置*/
  Print: {
    title: messages('finance-1.key299')/*打印设置*/,
    description: messages('finance-1.key300')/*您可在此页面配置借款单打印参数，系统会根据您配置的规则，自动生成相应的打印模版进行打印。*/,
    columns: [levelCode, levelOrgName, distributionList, optionPrintTemp, optionPrintDrc, optionWithLine, optionEncryptedBc, optionWithAppHist, isEnable],
    form: [],
    url: '/api/fm/print/option/query/dto/by/page',
    deleteUrl: '/api/fm/print/option/delete/dto?optionId',
    rule: PrintRule,
    icon: 'book'
  },
  /*借款设置*/
  Cash: {
    title: messages('finance-1.key301')/*借款设置*/,
    description: messages('finance-1.key302')/*您可在此页面配置借款单提交等配置；*/,
    columns: [levelCode, levelOrgName, fmLoanOptionDistList, isEnable],
    form: [],
    url: '/api/loan/option/list',
    deleteUrl: '/api/loan/option/delete?loanOptionId',
    rule: CashRule,
    icon: 'book'
  },
  /*借款类型*/
  Loan: {
    title: messages('finance-1.key17')/*借款类型*/,
    description: messages('finance-1.key303')/*您可在此页面配置借款类型、基于借款类型的借款管控（如：借款金额上限）与还款管控（如：还款期限）*/,
    columns: [levelCode, levelOrgName, classCode, loanDescription, isEnabled],
    form: [],
    url: '/api/cash/transaction/classes/query?typeCode=PREPAYMENT',
    rule: LoanRule,
    icon: 'bulb',
    moreTitle: messages('finance-1.key17')/*借款类型*/,
    moreContent: [
      messages('finance-1.key305')/*借款类型是企业区分不同借款业务的自定义档案，常见的如 员工差旅借款、部门备用金借款、供应商预付款等;*/,
      messages('finance-1.key306')/*可应用于借款单表单配置中，支持一张表单提交多种借款类型的借款申请;*/,
      messages('finance-1.key307')/*可在借款类型上进行企业的借款管控：欠款不清后款不借、借款金额上限等;*/,
      messages('finance-1.key308')/*可在借款类型上进行企业的还款管控：核销对象、强制核销、还款期限设定等;*/
    ]
  },
  /*支付基础配置*/
  PayBasic: {
    title: messages('finance-1.key309')/*支付基础配置*/,
    description: messages('finance-1.key310')/*您可在此页面配置支付业务的参数，系统会根据您配置的规则，对支付功能及流程进行管控。*/,
    columns: [levelCode, levelOrgName, fmPaymentOptionDistList, ablePaymentMethods, defPaymentMethods, isPartPay, isPayCheck, isEnablt],
    form: [],
    url: '/payment/api/finance/payment/list',
    deleteUrl: '/payment/api/finance/payment/delete?id',
    rule: PayBasicRule,
    icon: 'book'
  },
  /*付款方式*/
  PayType: {
    title: messages('finance-1.key311')/*付款方式*/,
    description: messages('finance-1.key312')/*您可在此页面定义企业的具体的付款方式，设置后，可在公司账户中授权，应用于实际支付操作时进行选择。*/,
    columns: [paymentMethodCategoryName, paymentMethodCode, description, isEnabled],
    form: [paymentMethodCodeSearch, descriptionSearch],
    url: '/payment/api/cash/payment/method/query',
    rule: PayTypeRule
  },
  /*账户授权*/
  Authorization: {
    title: messages('finance-1.key313')/*账户授权*/,
    description: messages('finance-1.key314')/*请授权可使用此账户进行支付操作的人员*/,
    columns: [
      { title: messages('finance-1.key315')/*公司代码*/, dataIndex: 'companyCode' },
      { title: messages('finance-1.key316')/*公司名称*/, dataIndex: 'companyName' },
      { title: messages('finance-1.key317')/*部门编码*/, dataIndex: 'departmentCode' },
      { title: messages('finance-1.key129')/*部门名称*/, dataIndex: 'departmentName' },
      { title: messages('finance-1.key318')/*被授权员工*/, dataIndex: 'employeeName' },
      { title: messages('finance-1.key319')/*有效日期从*/, dataIndex: 'authorizeDateFrom',
        render: recode => recode ? moment(recode).local().format('YYYY-MM-DD') : "-" },
      { title: messages('finance-1.key320')/*有效日期至*/, dataIndex: 'authorizeDateTo',
        render: value => value ? moment(value).local().format('YYYY-MM-DD') : "-" },
      isEnabled
    ],
    form: [],
    url: '/api/companyBankAuth/selectCompanyBankId',
    rule: AuthorizationRule
  },
  /*付款方式*/
  ApyType: {
    title: messages('finance-1.key311')/*付款方式*/,
    description: messages('finance-1.key321')/*授权此账号可使用的付款方式*/,
    columns: [paymentMethodCategoryName, paymentMethodCode, description],
    form: [],
    url: '/api/comapnyBankPayment/getByBankAccountId',
    deleteUrl: '/api/comapnyBankPayment/deleteById?id',
    rule: ApyTypeRule
  },
  /*核算基础配置*/
  Account: {
    title: messages('finance-1.key322')/*核算基础配置*/,
    description: messages('finance-1.key323')/*您可在此页面配置核算业务的参数，系统会根据您配置的规则，对分录导出的格式与样式进行管控。*/,
    columns: [levelCode, levelOrgName, optionalEptFmt, optionalEntryFmt, apiEntryFmt, isEnable],
    form: [],
    url: '/api/ledger/option/query/by/page',
    deleteUrl: '/api/ledger/option?optionId',
    rule: AccountRule,
    icon: 'book'
  },
  /*会计期间定义*/
  PeriodDefine: {
    title: messages('finance-1.key324')/*会计期间定义*/,
    description: messages('finance-1.key325')/*您可在此页面定义企业的会计期间模型，配置完成后，请进入会计期间控制菜单，打开期间后可应用于预算与核算相关功能；*/,
    columns: [periodSetCode, periodSetName, totalPeriodNum, periodAdditionalFlagDes],
    form: [periodSetCodeSearch],
    url: '/api/periodset',
    rule: PeriodDefineRule,
    onRow: (record, context) => {
      context.context.router.push(menuRoute.getRouteItem('period-define-detail', 'key').url.replace(":id", record.id))
    }
  },
  /*会计期间控制*/
  PeriodControl: {
    title: messages('finance-1.key326')/*会计期间控制*/,
    description: messages('finance-1.key327')/*可在此页面进行会计期间的关闭与打开，并影响核算功能的使用*/,
    columns: [
      { title: messages('finance-1.key291')/*账套编码*/, dataIndex: "setOfBooksCode" },
      { title: messages('finance-1.key294')/*账套名称*/, dataIndex: 'setOfBooksName' },
      periodSetCode,
      { title: messages('common.base.currency')/*本位币*/, dataIndex: 'functionalCurrencyCode' },
      { title: messages('finance-1.key328')/*科目表*/, dataIndex: 'accountSetCode' },
      enabled
    ],
    form: [setOfBooksCodeSearch, setOfBooksNameSearch],
    url: '/api/setOfBooks/query/dto',
    onRow: (record, context) => {
      if (!record.enabled) {
        Modal.info({
          title: messages('finance-1.key329')/*该账套被禁用*/,
          content: messages('finance-1.key330')/*禁用的账套无法打开或关闭会计期间*/,
          maskClosable: true
        });
        return
      }
      context.context.router.push(menuRoute.getRouteItem('account-period-detail', 'key').url.replace(":periodSetId", record.periodSetId).replace(':setOfBooksId', record.setOfBooksId))
    }
  },
  /*科目表定义*/
  Subject: {
    title: messages('finance-1.key331')/*科目表定义*/,
    description: messages('finance-1.key332')/*您可在此页面定义企业的科目表，可应用于产品的核算功能；*/,
    columns: [
      { title: messages('finance-1.key292')/*科目表编码*/, dataIndex: 'accountSetCode' },
      { title: messages('finance-1.key293')/*科目表名称*/, dataIndex: 'accountSetDesc' },
      enabled
    ],
    form: [accountSetCodeSearch, accountSetDescSearch],
    url: '/ledger/api/account/set/query',
    rule: SubjectRule,
    onRow: (record, context) => {
      context.context.router.push(menuRoute.getRouteItem('subject-sheet-detail', 'key').url.replace(":id", record.id))
    }
  },
  /*借还款全局查看*/
  loanGlobalView: {
    title: messages('finance-1.key333')/*全局查看*/,
    tableName: 'loan-global-view',
    columns: [payeeCode, payeeName, loanCompanyName, currencyCode,
      {
        title: messages('finance-1.key81')/*借款总额*/, dataIndex: 'loanSum',
        render: (value, record) =>  _this.filterMoney(value, queryCurrencyPrecision(record.currencyCode))
      },
      {
        title: messages('finance-1.key334')/*待还款总额*/, dataIndex: 'stayWriteOffSum',
        render: (value, record) => _this.filterMoney(value, queryCurrencyPrecision(record.currencyCode))
      }
    ],
    form: [payeeKey, loanCompanyNameSearch],
    url: '/api/global/list',
    onRow: (record, context) => {
      context.context.router.push({
        pathname: menuRoute.getRouteItem('overall-sub-list','key').url,
        state: { payeeId: record.payeeId, currencyCode: record.currencyCode, companyID: record.companyID, companyOID: record.companyOID }
      })
    }
  },
  /*还款管理*/
  repaymentSlipManagement: {
    title: messages('finance-1.key335')/*还款管理*/,
    tableName: 'repayment-slip-management',
    columns: [payeeCode, payeeName,
      {
        title: messages('finance-1.key336')/*还款提交日期*/, dataIndex: 'createDate', width:120,
        render: value => moment(value).format('YYYY-MM-DD')
      },
      { title: messages('finance-1.key337')/*还款人*/, dataIndex: 'fullName' },
      { title: messages('finance-1.key5')/*还款单号*/, dataIndex: 'businessCode' },
      { title: messages('finance-1.key74')/*借款单号*/, dataIndex: 'loanBusinessCode' }, currencyCode,
      {
        title: messages('finance-1.key12')/*还款金额*/, dataIndex: 'repaymentAmount',
        render:(value,record) => _this.filterMoney(value,queryCurrencyPrecision(record.currencyCode))
      }, origDocumentSequence
    ],
    form: context => ([dataRange, payeeKey, employeeKey,
      {
        id: 'businessCodeR', label: messages('finance-1.key5')/*还款单号*/, component: 'Input',
        dataIndex: 'businessCode'
      },
      {
        id: 'businessCodeL', label: messages('finance-1.key74')/*借款单号*/, component: 'Input',
        dataIndex: 'loanBusinessCode'
      },
      companyId, loanTypeId(context), currencyCodeForm(context), remarkForm,
      {
        id: 'status', label: messages('finance-1.key78')/*还款状态*/, component: <Radio.Group>
          { refundStatus.map(item => <Radio key={item.value} value={item.value}>{item.label}</Radio>) }
        </Radio.Group>,
        initialValue: '1001',
        decorator: {
          rules: [{ required: true }]
        },
        nullValue: '1001',
        tagUnclosed: true,
        row: true,
        tagParser: value => refundStatus.find(item => item.value === value).label,
        parser: value => ({ status: value === '100' ? ['1001', '1002', '1003'] : value })
      }
    ]),
    url: '/api/global/repayment/management',
    onRow: () => {}
  },
  /* 借款管理 */
  loanBillManagement: {
    title: messages('finance-1.key338')/*借款管理*/,
    tableName: 'loan-bill-management',
    columns: [
      {
        title: messages('common.document.code')/*单号*/, dataIndex: 'businessCode',
        render: (value, record) => <a onClick={e => handleLoanRowClick(e, record)}>{value}</a>
      }, loanCompanyName,
      {
        title: messages('finance-1.key80')/*申请人/代理人*/, dataIndex: 'applicantName',
        render: (value,record) => record.submittedBy === record.applicantOid ? value : `${value}/${record.submittedName}`
      },
      { title: messages('finance-1.key17')/*借款类型*/, dataIndex: 'loanTypeName' },
      { title: messages('finance-1.key6')/*借款行号*/, dataIndex: 'sequence' },
      {
        title: messages('finance-1.key339')/*借款提交日期*/, dataIndex: 'submittedDate', width:120,
        render: value => moment(value).format('YYYY-MM-DD')
      }, remark, payeeName, currencyCode,
      {
        title: messages('finance-1.key16')/*借款金额*/, dataIndex: 'amount',
        render: (value,record) => _this.filterMoney(value, queryCurrencyPrecision(record.currencyCode))
      },
      {
        title: messages('finance-1.key82')/*待还款金额*/, dataIndex: 'stayWriteOffAmount',
        render: (value,record) => _this.filterMoney(value, queryCurrencyPrecision(record.currencyCode))
      },
    ],
    form: context => ([dataRange, payeeKey, employeeKey,
      {
        id: 'businessCodeL', label: messages('finance-1.key74')/*借款单号*/, component: 'Input',
        dataIndex: 'businessCode'
      },
      companyId, loanTypeId(context), currencyCodeForm(context), remarkForm,
      {
        id: 'status', label: messages('finance-1.key78')/*还款状态*/, component: <Radio.Group>
          { loanStatus.map(item => <Radio key={item.value} value={item.value}>{item.label}</Radio>) }
        </Radio.Group>,
        initialValue: '1005',
        decorator: {
          rules: [{ required: true }]
        },
        row: true,
        nullValue: '1005',
        tagUnclosed: true,
        tagParser: value => loanStatus.find(item => item.value === value).label,
        parser: value => ({ status: value === '1000' ? ['1005', '1006', '1007'] : value === '1005' ? ['1005', '1006'] : value })
      }
    ]),
    url: '/api/global/loan/management',
    onRow: (record, context) => {
      SlideFrame.open({
        content: ViewLine,
        params: {
          viewId: record.id
        },
        title: messages('finance-1.key45')/*查看借款计划*/
      }, context)
    },
    footer: context => context.props.options.repaymentOption.repaymenTypes.indexOf(4) > -1 ? (
      <Importer
        btnName={messages('finance-1.key526')/*批量还款*/}
        onOk={() => context.tableRef.getList()}
        errorTableData={data => Importer.getUploadResult(data)}
        templateOptions={{
          templateList: [{
            templateName: messages('finance-1.key514')/*批量额度还款导入还款*/,
            downloadUrl: `/api/global/batch/repayment/template/download`,
            downloadMethod: 'get'
          }]
        }}
        uploadOptions={{
          uploadUrl: `/api/global/batch/repayment/uploading`,
          listenUrl: '/api/global/batch/repayment/query/error'
        }}
        uploadResultOptions={{
          shouldDownloadErrorInfo: true,
          getErrorTableVisible: uploadResult => uploadResult && uploadResult.failureEntities > 0,
          errorUrl: '/api/global/batch/repayment/download/error'
        }}
      />
    ) : null
  },
  exportTemplateSetting: {
    title: messages('finance-1.key340')/*报盘文件模版*/,
    description: messages('finance-1.key341')/*您可在此页面定义网银报盘文件的模版，并分配给对应银行，相应银行的银行账户在进行落地文件方式的支付时，会按照定义的模版生成报盘文件;*/,
    columns: [
      { title: messages('finance-1.key342')/*报盘文件模版编码*/, dataIndex: 'templateCode' },
      { title: messages('finance-1.key343')/*报盘文件模版名称*/, dataIndex: 'templateName' },
      { title: messages('finance-1.key344')/*分配银行*/, dataIndex: 'bankName' },
      { title: messages('finance-1.key345')/*是否预置*/, dataIndex: 'isPreset', render: value => value ? messages('common.yes')/*是*/ : messages('common.no')/*否*/ },
      isEnabled
    ],
    form: [],
    url: '/payment/api/nachaTemplate/findPage',
    rule: ExportRule,
    onRow: (record, context) => {
      !record.isPreset && context.context.router.push(menuRoute.getRouteItem('template-detail', 'key').url.replace(":id", record.id))
    }
  }
}
